<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>utilities</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >MetaGETA (Metadata Gathering, Extraction and Transformation)</th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Module&nbsp;utilities
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="utilities-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module utilities</h1><p class="nomargin-top"><span class="codelink"><a href="utilities-pysrc.html">source&nbsp;code</a></span></p>
<p>Utility helper functions</p>

<!-- ==================== CLASSES ==================== -->
<a name="section-Classes"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Classes</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Classes"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr bgcolor="#e8f0f8" >
  <th colspan="2" class="group-header"
    >&nbsp;&nbsp;&nbsp;&nbsp;Filesystem Utilities</th></tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="utilities.rglob-class.html" class="summary-name">rglob</a><br />
      A recursive/regex enhanced glob adapted from 
        os-path-walk-example-3.py - 
        http://effbot.org/librarybook/os-path.htm
    </td>
  </tr>
<tr bgcolor="#e8f0f8" >
  <th colspan="2" class="group-header"
    >&nbsp;&nbsp;&nbsp;&nbsp;Excel Utilities</th></tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="utilities.ExcelWriter-class.html" class="summary-name">ExcelWriter</a><br />
      A simple spreadsheet writer
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="utilities.ExcelReader-class.html" class="summary-name">ExcelReader</a><br />
      A simple spreadsheet reader
    </td>
  </tr>
</table>
<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr bgcolor="#e8f0f8" >
  <th colspan="2" class="group-header"
    >&nbsp;&nbsp;&nbsp;&nbsp;String Utilities</th></tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#encode" class="summary-sig-name">encode</a>(<span class="summary-sig-arg">string</span>)</span><br />
      Encode a unicode string</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#encode">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr bgcolor="#e8f0f8" >
  <th colspan="2" class="group-header"
    >&nbsp;&nbsp;&nbsp;&nbsp;Filesystem Utilities</th></tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>tuple</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#runcmd" class="summary-sig-name">runcmd</a>(<span class="summary-sig-arg">cmd</span>,
        <span class="summary-sig-arg">format</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">s</code><code class="variable-quote">'</code></span>)</span><br />
      Run a command</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#runcmd">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code>/<code>list</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#which" class="summary-sig-name">which</a>(<span class="summary-sig-arg">name</span>,
        <span class="summary-sig-arg">returnfirst</span>=<span class="summary-sig-default">True</span>,
        <span class="summary-sig-arg">flags</span>=<span class="summary-sig-default">1</span>,
        <span class="summary-sig-arg">path</span>=<span class="summary-sig-default">None</span>)</span><br />
      Search PATH for executable files with the given name.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#which">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>boolean</code>/<code>(str,boolean)</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#exists" class="summary-sig-name">exists</a>(<span class="summary-sig-arg">f</span>,
        <span class="summary-sig-arg">returnpath</span>=<span class="summary-sig-default">False</span>)</span><br />
      A case insensitive file existence checker</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#exists">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#readbinary" class="summary-sig-name">readbinary</a>(<span class="summary-sig-arg">data</span>,
        <span class="summary-sig-arg">offset</span>,
        <span class="summary-sig-arg">start</span>,
        <span class="summary-sig-arg">stop</span>)</span><br />
      Read binary data</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#readbinary">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#readascii" class="summary-sig-name">readascii</a>(<span class="summary-sig-arg">data</span>,
        <span class="summary-sig-arg">offset</span>,
        <span class="summary-sig-arg">start</span>,
        <span class="summary-sig-arg">stop</span>)</span><br />
      Read ASCII data</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#readascii">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#ByteOrder" class="summary-sig-name">ByteOrder</a>()</span><br />
      Determine byte order of host machine.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#ByteOrder">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_WinFileOwner"></a><span class="summary-sig-name">_WinFileOwner</span>(<span class="summary-sig-arg">filepath</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#_WinFileOwner">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_NixFileOwner"></a><span class="summary-sig-name">_NixFileOwner</span>(<span class="summary-sig-arg">uid</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#_NixFileOwner">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>dict</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#FileInfo" class="summary-sig-name">FileInfo</a>(<span class="summary-sig-arg">filepath</span>)</span><br />
      File information.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#FileInfo">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#uuid" class="summary-sig-name">uuid</a>(<span class="summary-sig-arg">filepath</span>)</span><br />
      Generate a uuid reproducible based on filename</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#uuid">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#uncpath" class="summary-sig-name">uncpath</a>(<span class="summary-sig-arg">filepath</span>)</span><br />
      Convert file path to UNC.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#uncpath">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str/list</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#normcase" class="summary-sig-name">normcase</a>(<span class="summary-sig-arg">filepath</span>)</span><br />
      Normalize case of pathname.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#normcase">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str/list</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#normpath" class="summary-sig-name">normpath</a>(<span class="summary-sig-arg">filepath</span>)</span><br />
      Normalize path, eliminating double slashes, etc.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#normpath">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str/list</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#realpath" class="summary-sig-name">realpath</a>(<span class="summary-sig-arg">filepath</span>)</span><br />
      Return the absolute version of a path.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#realpath">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#checkExt" class="summary-sig-name">checkExt</a>(<span class="summary-sig-arg">filepath</span>,
        <span class="summary-sig-arg">ext</span>)</span><br />
      Check a file has an allowed extension or apply a default extension if
      it has none.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#checkExt">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="utilities-module.html#volname" class="summary-sig-name">volname</a>(<span class="summary-sig-arg">path</span>)</span><br />
      Get the volume label for a CD/DVD</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#volname">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="writable"></a><span class="summary-sig-name">writable</span>(<span class="summary-sig-arg">filepath</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#writable">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr bgcolor="#e8f0f8" >
  <th colspan="2" class="group-header"
    >&nbsp;&nbsp;&nbsp;&nbsp;Exception Utilities</th></tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ExceptionInfo"></a><span class="summary-sig-name">ExceptionInfo</span>(<span class="summary-sig-arg">maxTBlevel</span>=<span class="summary-sig-default">0</span>)</span><br />
      Get info about the last exception</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#ExceptionInfo">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="FormatTraceback"></a><span class="summary-sig-name">FormatTraceback</span>(<span class="summary-sig-arg">trbk</span>,
        <span class="summary-sig-arg">maxTBlevel</span>)</span><br />
      Format traceback</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="utilities-pysrc.html#FormatTraceback">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Variables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="dateformat"></a><span class="summary-name">dateformat</span> = <code title="'%Y-%m-%d'"><code class="variable-quote">'</code><code class="variable-string">%Y-%m-%d</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="timeformat"></a><span class="summary-name">timeformat</span> = <code title="'%H:%M:%S'"><code class="variable-quote">'</code><code class="variable-string">%H:%M:%S</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="datetimeformat"></a><span class="summary-name">datetimeformat</span> = <code title="'%Y-%m-%dT%H:%M:%S'"><code class="variable-quote">'</code><code class="variable-string">%Y-%m-%dT%H:%M:%S</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="encoding"></a><span class="summary-name">encoding</span> = <code title="'latin-1'"><code class="variable-quote">'</code><code class="variable-string">latin-1</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="iswin"></a><span class="summary-name">iswin</span> = <code title="True">True</code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="__package__"></a><span class="summary-name">__package__</span> = <code title="None">None</code>
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="encode"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">encode</span>(<span class="sig-arg">string</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#encode">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Encode a unicode string</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>string</code></strong> (<code>unicode</code>) - Unicode string</li>
    </ul></dd>
    <dt>Returns: <code>str</code></dt>
        <dd>Encoded string</dd>
  </dl>
</td></tr></table>
</div>
<a name="runcmd"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">runcmd</span>(<span class="sig-arg">cmd</span>,
        <span class="sig-arg">format</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">s</code><code class="variable-quote">'</code></span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#runcmd">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Run a command</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>cmd</code></strong> (<code>str</code>) - Command (inc arguments) to run</li>
    </ul></dd>
    <dt>Returns: <code>tuple</code></dt>
        <dd>Returns (exit_code,stdout,stderr)</dd>
  </dl>
</td></tr></table>
</div>
<a name="which"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">which</span>(<span class="sig-arg">name</span>,
        <span class="sig-arg">returnfirst</span>=<span class="sig-default">True</span>,
        <span class="sig-arg">flags</span>=<span class="sig-default">1</span>,
        <span class="sig-arg">path</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#which">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Search PATH for executable files with the given name.</p>
  <p>On newer versions of MS-Windows, the PATHEXT environment variable will
  be set to the list of file extensions for files considered executable. 
  This will normally include things like &quot;.EXE&quot;. This fuction 
  will also find files with the given name ending with any of these 
  extensions.</p>
  <p>On MS-Windows the only flag that has any meaning is os.F_OK. Any other
  flags will be ignored.</p>
  <p>Derived mostly from <a 
  href="http://code.google.com/p/waf/issues/detail?id=531" 
  target="_top">http://code.google.com/p/waf/issues/detail?id=531</a> with 
  additions from Brian Curtins patch - <a 
  href="http://bugs.python.org/issue444582" 
  target="_top">http://bugs.python.org/issue444582</a></p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>name</code></strong> (<code>str</code>) - The name for which to search.</li>
        <li><strong class="pname"><code>returnfirst</code></strong> (<code>boolean</code>) - Return the first executable found.</li>
        <li><strong class="pname"><code>flags</code></strong> (<code>int</code>) - Arguments to <a 
          href="http://docs.python.org/library/os.html#os.access" 
          target="_top">os.access</a>.</li>
    </ul></dd>
    <dt>Returns: <code>str</code>/<code>list</code></dt>
        <dd>Full path to the first matching file found or a list of the full 
          paths to all files found, in the order in which they were found.</dd>
  </dl>
</td></tr></table>
</div>
<a name="exists"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">exists</span>(<span class="sig-arg">f</span>,
        <span class="sig-arg">returnpath</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#exists">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>A case insensitive file existence checker</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>f</code></strong> (<code>str</code>) - The filepath to check.</li>
        <li><strong class="pname"><code>returnpath</code></strong> (<code>boolean</code>) - Return the case sensitive path.</li>
    </ul></dd>
    <dt>Returns: <code>boolean</code>/<code>(str,boolean)</code></dt>
        <dd>True/False, optionally full path to the case sensitive path</dd>
  </dl>
</td></tr></table>
</div>
<a name="readbinary"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">readbinary</span>(<span class="sig-arg">data</span>,
        <span class="sig-arg">offset</span>,
        <span class="sig-arg">start</span>,
        <span class="sig-arg">stop</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#readbinary">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Read binary data</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>data</code></strong> (<code>str</code>) - data read from binary file</li>
        <li><strong class="pname"><code>offset</code></strong> (<code>int</code>) - Number of bytes to skip</li>
        <li><strong class="pname"><code>start</code></strong> (<code>int</code>) - Byte to start reading from (from offset, not beginning of data)</li>
        <li><strong class="pname"><code>stop</code></strong> (<code>int</code>) - Byte to stop reading at (from offset, not beginning of data)</li>
    </ul></dd>
    <dt>Returns: <code>str</code></dt>
        <dd>String</dd>
  </dl>
</td></tr></table>
</div>
<a name="readascii"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">readascii</span>(<span class="sig-arg">data</span>,
        <span class="sig-arg">offset</span>,
        <span class="sig-arg">start</span>,
        <span class="sig-arg">stop</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#readascii">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Read ASCII data</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>data</code></strong> (<code>str</code>) - data read from ASCII file</li>
        <li><strong class="pname"><code>offset</code></strong> (<code>int</code>) - Number of characters to skip</li>
        <li><strong class="pname"><code>start</code></strong> (<code>int</code>) - Character to start reading from (from offset, not beginning of 
          data)</li>
        <li><strong class="pname"><code>stop</code></strong> (<code>int</code>) - Character to stop reading at (from offset, not beginning of data)</li>
    </ul></dd>
    <dt>Returns: <code>str</code></dt>
        <dd>String</dd>
  </dl>
</td></tr></table>
</div>
<a name="ByteOrder"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">ByteOrder</span>()</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#ByteOrder">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Determine byte order of host machine.</p>
  <dl class="fields">
    <dt>Returns: <code>str</code></dt>
        <dd>String</dd>
  </dl>
</td></tr></table>
</div>
<a name="FileInfo"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">FileInfo</span>(<span class="sig-arg">filepath</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#FileInfo">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>File information.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filepath</code></strong> (<code>str</code>) - Path to file</li>
    </ul></dd>
    <dt>Returns: <code>dict</code></dt>
        <dd>Dictionary containing file: size, datemodified, datecreated, 
          dateaccessed, ownerid &amp; ownername</dd>
  </dl>
</td></tr></table>
</div>
<a name="uuid"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">uuid</span>(<span class="sig-arg">filepath</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#uuid">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Generate a uuid reproducible based on filename</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filepath</code></strong> (<code>str</code>) - Path to file</li>
    </ul></dd>
    <dt>Returns: <code>str</code></dt>
        <dd>uuid</dd>
  </dl>
</td></tr></table>
</div>
<a name="uncpath"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">uncpath</span>(<span class="sig-arg">filepath</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#uncpath">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Convert file path to UNC.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filepath</code></strong> (<code>str</code>) - Path to file</li>
    </ul></dd>
    <dt>Returns: <code>str</code></dt>
        <dd>UNC filepath (if on Windows)</dd>
  </dl>
</td></tr></table>
</div>
<a name="normcase"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">normcase</span>(<span class="sig-arg">filepath</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#normcase">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Normalize case of pathname. Makes all characters lowercase and all 
  slashes into backslashes.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filepath</code></strong> (<code>str/list</code>) - Path to file/s</li>
    </ul></dd>
    <dt>Returns: <code>str/list</code></dt>
        <dd>Path to file/s</dd>
  </dl>
</td></tr></table>
</div>
<a name="normpath"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">normpath</span>(<span class="sig-arg">filepath</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#normpath">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Normalize path, eliminating double slashes, etc.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filepath</code></strong> (<code>str/list</code>) - Path to file/s</li>
    </ul></dd>
    <dt>Returns: <code>str/list</code></dt>
        <dd>Path to file/s</dd>
  </dl>
</td></tr></table>
</div>
<a name="realpath"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">realpath</span>(<span class="sig-arg">filepath</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#realpath">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Return the absolute version of a path.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filepath</code></strong> (<code>str/list</code>) - Path to file/s</li>
    </ul></dd>
    <dt>Returns: <code>str/list</code></dt>
        <dd>Path to file/s</dd>
  </dl>
<div class="fields">      <p><strong>Note:</strong>
        os.path.realpath/os.path.abspath returns unexpected results on 
        windows if filepath[-1]==':'
      </p>
</div></td></tr></table>
</div>
<a name="checkExt"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">checkExt</span>(<span class="sig-arg">filepath</span>,
        <span class="sig-arg">ext</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#checkExt">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Check a file has an allowed extension or apply a default extension if 
  it has none.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filepath</code></strong> (<code>str</code>) - Path to file</li>
        <li><strong class="pname"><code>ext</code></strong> (<code>[str,...,str]</code>) - Allowed file extensions, ext[0] is the default</li>
    </ul></dd>
    <dt>Returns: <code>str</code></dt>
        <dd>Path to file with updated extension</dd>
  </dl>
</td></tr></table>
</div>
<a name="volname"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">volname</span>(<span class="sig-arg">path</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="utilities-pysrc.html#volname">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Get the volume label for a CD/DVD</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>path</code></strong> (<code>str</code>) - Disc path</li>
    </ul></dd>
    <dt>Returns: <code>str</code></dt>
        <dd>Volume label</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >MetaGETA (Metadata Gathering, Extraction and Transformation)</th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    &nbsp;
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
